//microcommand define random-permutation
signature("<...items:fragment>", { strictOptions: true })
option("count", "-n <n:integer>")
action(({ session, options }, ...params) => {
  if (params.length <= 0) return session.text(".empty")
  var n = 0
  if (typeof options.count === "number") n = options.count
  if (n > params.length) return session.i18n(".insufficient", [n])
  if (n <= -params.length) return session.i18n(".negative-too-many")
  if (n <= 0) n = n + params.length
  const ind = Array.from({ length : params.length }, (_, index) => index)
  const out = []
  for (let i = 0; i < n; i++) {
    const j = Math.floor(Math.random() * (params.length - i)) + i
    const sel = ind[j]
    if (i > 0) out.push(" ")
    out.push(params[sel])
    ind[j] = ind[i]
  }
  return out.flat()
})
locale("zh-CN", { description: "将输入的项随机排列", arguments: { items: "排序项" }, options: { count: "正数：随机选取其中若干项排列，如3为取3项；负数：随机去掉其中若干项排列，如-1为去掉1项；零或不填：排列所有项。" }, messages: { empty: "输入为空...", insufficient: "输入不足 {0} 项...", "negative-too-many": "去除数量过多...", } })